<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 主页</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">    
    <link href="{$Think.config.site.resource_url}css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        #listtable .fa{    cursor: pointer;color: #1ab394;margin-right: 1em;}
    </style>
</head>

<body >
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
            <style type="text/css">.col-sm-12 label{ font-weight:300; }</style>
            <div class="ibox float-e-margins">
                <div class="">
                    <h5>{:lang('地推列表')}</h5>
                </div>
                <div class="row ibox-title">
                    <form action="" method="post" name="leaseorder">
                        <label><button type="button" class="btn btn-sm btn-primary btn123" id="addBtn"> {:lang('添加地推')}</button>　　</label>
                        <br>
                        <label>{:lang('归属代理商')}：</label>
                        <label>
                            <select data-placeholder="选择代理商......" class="chosen-select  form-control" id='oid' name="belong_agent" style="width:150px;" tabindex="2">
                                <option value="">{:lang('选择代理商')}</option>
                                <?php foreach($agent as $kk => $vo) {?>
                                <option value="{$kk}" hassubinfo="true" <?php if(!empty($belong_agent) && $kk == $belong_agent) echo "selected";?>>{$vo}</option>
                                <?php }?>
                            </select>
                        </label>
                        <label>{:lang('用户状态')}：</label>
                        <label>
                            <select data-placeholder="选择状态......" class="chosen-select  form-control" id='status' name="status" style="width:150px;" tabindex="2">
                                <option value="">{:lang('选择状态')}</option>
                                {volist name="status" key="kk" id="vo"}
                                <option value="{$kk}" hassubinfo="true" <?php if (!empty($is_use) && $kk == $is_use) echo "selected";?>>{$vo}</option>
                                {/volist}
                            </select>
                        </label>
                        <label>{:lang('地推姓名')}：</label>
                        <label><input type="text" class="input-sm form-control" name="real_name" value="{$real_name ?? ''}" aria-controls="" placeholder="{:lang('输入')}{:lang('地推姓名')}"></label>
                        <label>{:lang('手机号码')}：</label>
                        <label><input type="text" class="input-sm form-control" name="phone" value="{$phone ?? ''}" aria-controls="" placeholder="{:lang('输入')}{:lang('手机号')}"></label>
                        <label><button type="submit" class="btn btn-sm btn-primary btn123"> {:lang('提交')}</button> </label>
                    </form>
                </div>
                <div class="tips" style="color:#1ab394">
                    <p class="tips_title">地推登录平台：<b style="color: red;">{$Think.config.officialwebsite}/home/index/index</b> 使用绑定手机号即可登录</p>
                </div>

                <div class="ibox-content">

                    <table class="table table-hover" id="listtable">
                        <thead>
                            <tr>
                                <th>{:lang('地推姓名')}</th>
                                <th>{:lang('证件号')}</th>
                                <th>{:lang('手机号码')}</th>
                                <th>{:lang('归属代理商')}</th>
                                <th>{:lang('用户状态')}</th>
                                <th>{:lang('添加时间')}</th>
                                <th>{:lang('操作')}</th>
                            </tr>
                        </thead>
                        <tbody>
                            {volist name="list" id="v"}
                            <tr data-id="{$v.id}">
                                <td>{$v.real_name}</td>
                                <td>{$v.card_sn}</td>
                                <td>{$v.phone}</td>
                                <td><?php echo $agent[$v['belong_agent']]?></td>
                                <td>{$status[$v['is_use']]}</td>
                                <td><?php if (!empty($v['addtime'])) echo date('Y-m-d H:i', $v['addtime']);?></td>
                                <td>
                                    <?php
                                        if ($v['is_use'] == 1) {
                                    ?>
                                    <i class="fa fa-forbiddent change_status"  data-id="{$v.id}" style="color:red"> {:lang('禁用')} </i>
                                    <?php }else { ?>
                                    <i class="fa fa-forbiddent change_status"  data-id="{$v.id}"> {:lang('启用')} </i>
                                    <?php }?>
                                    <i class="fa fa-edit"> {:lang('修改')}</i>
                                </td>
                            </tr>
                            {/volist}
                        </tbody>
                    </table>
                </div>

                <div class="row">
                    <div class="row">
                        <div class="col-sm-5">
                            <div class="dataTables_info" id="DataTables_Table_0_info" role="alert" aria-live="polite" aria-relevant="all"></div>
                        </div>
                        <div class="col-sm-7">
                            <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                {$list->render()}
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            </div>
        </div>
    </div>
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/peity/jquery.peity.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>

    <script>

    var layer_font;
    var $editTr;
        $(document).ready(function() {
            $("#addBtn").bind("click",function(){
                layer_font = layer.open({
                  type: 2,
                  title: "{:lang('添加地推')}",
                  shadeClose: true,
                  shade: 0.8,
                  area: ['80%', '90%'],
                  content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Agent/add_employee' //iframe的url
                });
            });

            //修改按钮
            $("#listtable").on("click",".fa-edit",function(){
                $editTr = $(this).closest("tr");
                var id = $editTr.data("id");
                layer_font = layer.open({
                  type: 2,
                  title: "{:lang('修改地推')}",
                  shadeClose: true,
                  shade: 0.8,
                  area: ['80%', '90%'],
                  content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Agent/edit_employee?id='+id //iframe的url
                });
            })

            $(".change_status").on("click",function(){
                var id = $(this).attr('data-id');
                layer.confirm("{:lang('确定要更改状态吗？')}", {
                        btn: ["{:lang('确定')}","{:lang('取消')}"], //按钮
                        shade: false //不显示遮罩
                    }, function(){
                        //确定禁用
                        $.ajax({
                            type : 'POST',//delete
                            url : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Agent/change_status?id='+id,
                            dataType : 'json',
                            data : {id:id},
                            async:false,
                            success : function(result) {
                                if(0 === result.code) {
                                    layer.msg(result.msg, {icon: 1});
                                    window.location.reload();
                                }  else  {
                                    layer.msg(result.msg, {icon: 5});
                                }
                            },
                            error : function(){
                                res = false;
                                layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                            }
                        })
                    },
                    function(){

                    });

            });

        }); 
    </script>
    <!--统计代码，可删除-->

</body>

</html>
